package com.caifu.controller.healthArchive;

import com.caifu.controller.AbstractController;
import com.caifu.pojo.SysUser;
import com.caifu.service.IHealthArchiveService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
* 
* 功能描述：老人血糖信息
*
* @Author  GZ
* @Date   2020/11/17 17:34
*/
@Controller
@RequestMapping("/healthArchive/bloodSugar")
public class BloodSugarController extends AbstractController {

    @Autowired
    private IHealthArchiveService archiveService;

    /**
    * 
    * 功能描述：查询血糖条记录信息
    *
    * @Author  GZ
    * @Date   2020/11/17 17:36
    */
    @RequestMapping("obtainData")
    @ResponseBody
    public JSONObject obtainData(int pageNum, int pageSize
            , String startDate, String endDate, String userNo){
        try {
            return archiveService.pagedQueryUserBloodSugarInfo(
                    pageNum,pageSize,startDate,endDate,userNo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
    * 
    * 功能描述：保存血糖信息
    *
    * @Author  GZ
    * @Date   2020/11/17 17:37
    */
    @RequestMapping("saveData")
    @ResponseBody
    public JSONObject saveData(String userNo,String bloodGlucose){
        SysUser sysUser =getUser();
        try {
            return archiveService.saveBloodSugarInfo(userNo,bloodGlucose,sysUser);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
    * 
    * 功能描述：删除选中的记录
    *
    * @Author  GZ
    * @Date   2020/11/19 10:51
    */
    @RequestMapping("deleteData")
    @ResponseBody
    public JSONObject deleteData(String dataInfo){
        try {
            return archiveService.deleteBloodSugarInfo(dataInfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
